#include <iostream>
using namespace std;
int a[100005],ans=0,n;
void dfs(int step,string nowcolor,int lastred,int lastblue,int score){
    if(step>n){
        ans=max(ans,score);
        return;
    }
    if(nowcolor=="red"){
        if(a[step]==a[lastred]) score+=a[step];
        dfs(step+1,"red",step,lastblue,score);
        dfs(step+1,"blue",step,lastblue,score);
    }
    else{
        if(a[step]==a[lastblue]) score+=a[step];
        dfs(step+1,"red",lastred,step,score);
        dfs(step+1,"blue",lastred,step,score);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    for(int k=1;k<=t;k++){
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        dfs(1,"red",0,0,0);
        dfs(1,"blue",0,0,0);
        cout<<ans<<endl;
    }
    return 0;
}
